Control device with time measuring function

ABSTRACT

A control device with a time measuring function measures a turned-off time of an ignition switch with a low consumption current and high accuracy at a level adapted for a demand from the controlling side, as well as a turned-on time of the ignition switch. The control device also measures an accumulative turned-on time of the ignition switch. The control device comprises a battery, a microcomputer for computing a control variable to control a control target, a time measuring unit, a clock source for the microcomputer, a clock source for the time measuring unit, and a unit for changing over operation of the time measuring unit depending on an intended use. The time measuring unit operates regardless of run/stop of the microcomputer.

BACKGROUND OF THE INVENTION

1. Field of the Invention

The present invention relates to a time measuring technique for use in acontrol device.

2. Description of the Related Art

An engine electronic control unit (ECU) has recently faced a demand forcontrol to measure a time during which an engine has stopped. Measuringa time during which an ignition switch is turned off, i.e., a timeduring which the engine electronic control unit is stopped, is requiredto predict, based on the time from the preceding engine stop, a coolinglevel of the engine and the amounts by which engine oil has dropped andrestored, and then to modify control parameters at the next enginestartup.

A known technique for satisfying such a demand is disclosed in, e.g.,Patent Reference 1 (JP,A 2002-341067). According to the known technique,a dedicated circuit comprising a comparator, a capacitor, etc. isprovided to measure a turned-off time of an ignition switch.

With the disclosed method, a microcomputer is started up at intervals ofa constant time to measure the charging/discharging time of thecapacitor and the number of times at which the capacitor has beencharged and discharged, and the turned-off time of the ignition switchis measured by counting the number of times at which the capacitor hasbeen charged and discharged.

SUMMARY OF THE INVENTION

However, the disclosed method has a possibility of deterioration inaccuracy of the time measurement because it utilizes thecharging/discharging of the capacitor. Another problem is that themicrocomputer is started up to count the number of times at which thecapacitor has been charged and discharged, a consumption currentincreases during the operation of the microcomputer.

Further, the disclosed method has just means for measuring theturned-off time of the ignition switch. In other words, because thedisclosed method cannot measure a time during which the engine hasoperated, it is impossible to calculate the lifetime up to now which isrequired to predict aging and other secular changes of engineauxiliaries, etc.

Accordingly, it is an object of the present invention to measure aturned-off time of an ignition switch with a low consumption current andhigh accuracy at a level adapted for a demand from the controlling side,as well as a turned-on time of the ignition switch. Another object ofthe present invention is to measure an accumulative turned-on time ofthe ignition switch.

To achieve the above objects, the present invention provides a controldevice with a time measuring function comprising a battery, amicrocomputer for computing a control variable to control a controltarget, a time measuring unit, a clock source for the microcomputer, anda separate clock source for the time measuring unit being independent ofthe clock source for the microcomputer, the time measuring unitoperating regardless of run/stop of the microcomputer.

According to the present invention, the turned-off time of the ignitionswitch can be measured with a low consumption current and high accuracyat a level adapted for a demand from the controlling side. Further, theturned-on time of an ignition switch can be measured, and anaccumulative turned-on time of the ignition switch can also be stored.

BRIEF DESCRIPTION OF THE DRAWINGS

FIG. 1 is a block diagram showing an embodiment of a control device towhich the present invention is applied;

FIG. 2 is a block diagram showing a detailed internal configuration of apart of the control device shown in FIG. 1;

FIG. 3 is a table showing states of a clock source in the control deviceshown in FIG. 1;

FIG. 4 illustrates state transitions of the control device shown in FIG.1;

FIG. 5 is a time-serial waveform chart for the control device shown inFIG. 1;

FIG. 6 is a flowchart when a microcomputer is started up; and

FIG. 7 is a flowchart when the microcomputer is stopped.

DESCRIPTION OF THE PREFERRED EMBODIMENTS

FIG. 1 is a block diagram of a control device showing one embodiment ofthe present invention. A control device (electronic control unit (ECU))2 has at least two inputs for a power supply line 1 a directly connectedto a battery 1 and a signal line to receive a signal 3 a from anignition switch 3.

A voltage of the battery 1 is supplied to a regulator 4 and a timermodule 11. Source power from the battery 1 can be supplied to theregulator 4 and the timer module 11 regardless of whether the ignitionswitch 3 is turned on or off.

The ignition switch signal 3 a is supplied to the timer module 11 and amicrocomputer 7 in the control device 2. The timer module 11 and themicrocomputer 7 determine whether the ignition switch 3 is turned on oroff. The timer module 11 comprises an oscillator (OSC) 5, a powercontroller 6, an SPI 8, an oscillator controller 9, and a timer 10.

The microcomputer 7 is associated with an oscillator 12 serving as aclock source. The clock sources for the timer module 11 and themicrocomputer 7 are constituted by the respective oscillators 5, 12different from each other, and the timer module 11 and the microcomputer7 are implemented as individual devices. Data is transmitted andreceived between the timer module 11 and the microcomputer 7 via acommunication line 7 a. An electrically rewritable nonvolatile memory 13stores a program executed by the microcomputer 7, and also has an areain which measured timer values are written.

In this embodiment, the timer module 11 is completely independent of themicrocomputer 7 and can be operated even when no power is supplied tothe microcomputer 7. Thus, when time measurement is performed by thetimer module 11 while the control device 2 is stopped, no power issupplied to the microcomputer 7. Accordingly, a consumption current canbe reduced. While the nonvolatile memory 13 is shown as being presentexternally of the microcomputer 7 in this embodiment, the nonvolatilememory 13 may be incorporated in the microcomputer 7.

A description is now made of a flow of processing in each block when theignition switch 3 is turned on. The ignition switch signal 3 a isinputted to the power controller 6 in the timer module 11. In responseto detection of the turning-on of the ignition switch 3, the powercontroller 6 starts up the regulator 4.

When the regulator 4 is started up, a predetermined voltage is suppliedto the power supply line 4 a and the microcomputer 7 starts theoperation. The microcomputer 7 recognizes the turning-on of the ignitionswitch signal 3 a and starts up an OS (Operating System). Also, thepower controller 6 receives a power hold signal 8 a from themicrocomputer 7 through the SPI 8.

In this embodiment, the power hold signal 8 a is supplied from themicrocomputer 7 to the SPI 8 via the communication line 7 a extendingbetween them, and then inputted to the power controller 6 after beingdecoded in the SPI 8. The power hold signal 8 a is used to execute akey-off sequence in the microcomputer 7 when the ignition switch 3 isturned off.

First, when the ignition switch 3 is turned on, the microcomputer 7transmits the power hold signal 8 a=1 to the power controller 6 throughthe SPI 8 for holding the power controller 6 in an on-state.

Then, when the microcomputer 7 recognizes the turning-off of theignition switch 3 based on the ignition switch signal 3 a, it executesthe key-off sequence.

After the completion of the key-off sequence, the microcomputer 7transmits the power hold signal 8 a=0 through the SPI 8.Correspondingly, the power controller 6 outputs a power control signal 6a=0 to turn off the regulator 4.

The timer 10 for measuring time operates with the oscillator 5 servingas a clock source. A counter value of the time measuring timer 10 issent to the microcomputer 7 via a counter signal line 10 a, the SPI 8and the SPI communication line 7 a, thus enabling the microcomputer 7 toread the counter value.

Also, the operation of the time measuring timer 10 is controlled by themicrocomputer 7 through the SPI 8 in accordance with a value of a timerstart signal 8 b. In other words, the value of the timer start signal 8b controls the run/stop of the time measuring timer 10. When theoscillator controller 9 recognizes the timer start signal 8 b=1outputted from the microcomputer 7, it outputs an oscillator controlsignal 9 a=1 to the oscillator 5.

When the oscillator 5 recognizes the oscillator control signal 9 a=1, itstarts the operation. Then, the time measuring timer 10 starts theoperation while receiving, as a clock source, a clock signal 5 a fromthe oscillator 5. As a result, the timer 10 is able to measure time.

FIG. 2 is a block diagram showing a detailed internal configuration ofthe regulator 4, the oscillator 5, the power controller 6, theoscillator controller 9, and the time measuring timer 10.

The regulator 4 used in this embodiment is a linear regulator, butanother type regulator, e.g., a switching regulator, can also be used. Atransistor 21 is controlled by an error amplifier 25 so that thepredetermined voltage is outputted to the power supply line 4 a.

The voltage of the power supply line 4 a is compared in the erroramplifier 25 with a band gap reference 26 as an absolute referencevoltage. A control signal 25 a from the error amplifier 25 is outputtedto the transistor 21 through a pre-driver 28 for the transistor 21. Agate voltage of the transistor 21 is thereby linearly controlled toproduce the predetermined voltage.

The power control signal 6 a from the power controller 6 is inputted tothe pre-driver 28 to control the run/stop of the regulator 4. The powercontrol signal 6 a=1 starts the operation of the regulator 4, and 6 a=0conversely stops the operation of the regulator 4.

A power-on reset unit 30 initializes a counter 37 of the time measuringtimer 10, etc. provided in the control device 2 so that the controldevice 2 is brought into an initial state when the battery 1 isconnected.

The power controller 6 determines the operation based on two inputsignals, i.e., the ignition switch signal 3 a and the power hold signal8 a. The ignition switch signal 3 a is directly inputted to an OR gate31. The power hold signal 8 a from the microcomputer 7 is inputted tothe OR gate 31 through the SPI 8.

Herein, a command value from the microcomputer 7 is given as the powerhold signal 8 a=1 when the power is held, and as the power hold signal 8a=0 when the power is shut down. Therefore, a controller 33 outputs thepower control signal 6 a=1 in response to the ignition switch signal 3a=1 or the power hold signal 8 a=1 from the microcomputer 7. The powercontrol signal 6 a=1 enables the operation of the pre-driver 28.

Conversely, the controller 33 outputs the power control signal 6 a=0 inresponse to the ignition switch signal 3 a=0 or the power hold signal 8a=0 from the microcomputer 7, thereby disabling the operation of thepre-driver 28.

The oscillator controller 9 comprises an overflow sensor 34 and acontroller 36. The overflow sensor 34 senses an overflow of the counter37 of the time measuring timer 10. Upon sensing the overflow, theoverflow sensor 34 outputs an overflow signal 34 a=1 to the controller36. Conversely, when there occurs no overflow, the overflow sensor 34outputs an overflow signal 34 a=0 to the controller 36.

The controller 36 controls the operations of both the oscillator 5 andthe time measuring timer 10 in accordance with two input signals, i.e.,the overflow signal 34 a and the timer start signal 8 b.

Respective states of those signals are described in more detail belowwith reference to FIG. 3. The oscillator 5 operates at oscillationfrequency of 32.768 kHz, for example. The time measuring timer 10comprises a frequency divider 38 and the counter 37. Herein, theoscillation frequency of 32.768 kHz from the oscillator 5 is divided to½¹⁵ by the frequency divider 38 so that the LSB of the counter 37 is onesecond from the viewpoint of control demand. In this embodiment, thecounter 37 is constituted as an 18-bit counter.

FIG. 3 is a table showing run/stop states of the oscillator 5 inaccordance with the timer start signal 8 b from the microcomputer 7 andthe overflow signal 34 a from the time measuring timer 10. The followingdescription is made of, in particular, the case in which the ignitionswitch 3 is turned off, i.e., the regulator 4 is stopped.

When the timer start signal 8 b=0 is inputted, the oscillator 5 isstopped. As the oscillator 5 is stopped while the regulator 4 isstopped, the consumption current is minimized. (See state 45)

When the timer start signal 8 b=1 is inputted, the run/stop of theoscillator 5 is determined based on the overflow signal 34 a. During aperiod of the timer start signal 8 b=1, the turned-off time of theignition switch 3 is measured. Stated another way, during that period,the counter 37 continues the count-up. (See state 46)

Assuming, as described above, that the LSB of the counter 37 is onesecond, because the counter 37 is constituted as a 18-bit counter, thetimer function of this embodiment is able to measure the turned-off timeof the ignition switch 3 for h'3FFFF seconds, i.e., 72.8 hours, with aresolution of one second.

Also, when the counter 37 overflows and the overflow signal 34 a=1 isinputted, the overflow is sensed by the overflow sensor 34 to hold thecount value of the counter 37, and at the same time the oscillator 5 isstopped. (See state 47) Thus, the stop of the oscillator 5 brings theconsumption current into the same state as 45, whereby the consumptioncurrent is minimized.

As described above, this embodiment can provide a process capable ofmeasuring the turned-off time of the ignition switch 3 until 72.8 hourswith a resolution of one second, and reducing the consumption currentafter the measurement for 72.8 hours.

Further, during the period of the timer start signal 8 b=1, the counter37 continues the count-up. Unless the microcomputer 7 stops theoperation of the counter 37 of the time measuring timer 10, the counter37 successively counts up one per second even after the ignition switchsignal 3 a has been turned on.

FIG. 4 illustrates state transitions of the oscillator 5 and the timemeasuring timer 10 during the turned-off period of the ignition switch3.

An initial state is denoted by 51. In the initial state 51, the battery1 is in a shutdown state. Therefore, the voltage of the power supplyline 1 a is 0 V and all the functions of the control device 2 arestopped. When the battery 1 is connected, the voltage of the powersupply line 1 a rises to a battery voltage.

When the voltage at which the control device 2 is operable, e.g., thevoltage of the power supply line 1 a≧6 V, is detected, the power-onreset unit 30 clears the counter 37 of the time measuring timer 10 to 0.Also, because of the timer start signal 8 b=0, the state transits to 52.

In that state, when the microcomputer 7 reads the counter 37 of the timemeasuring timer 10 at the startup, the counter 37=0 is read. When thecounter 37=0 is read, the microcomputer 7 recognizes that batterydisconnection has occurred.

When the timer start signal 8 b=1 is set in the state 52, the counter 37of the time measuring timer 10 starts the count-up from 1 (state 53). Ifthe counter 37 starts the count-up from 0, the microcomputer 7 reads 0when it reads the timer value, i.e., the count value of the counter 37,before counting one second.

On that occasion, the microcomputer 7 may erroneously recognize thatbattery disconnection has occurred. In consideration of such apossibility, the counter 37 is designed to start the count-up from 1 inresponse to the timer start signal 8 b=1. This avoids the microcomputer7 from making erroneous recognition.

When the counter 37 starts the count-up from 1, the state automaticallytransits to 54 in which the counter 37 successively counts up one persecond until reaching h'3FFFF. When the counter 37 counts up to h'3FFFF,the overflow sensor 34 senses an overflow of the counter 37 and theoverflow signal 34 a=1 is set.

At that time, the controller 36 sets an oscillator control signal 36 a=0and a counter control signal 36 b=0, thereby stopping the oscillator 5and holding the counter 37 (state 55). Also, when the timer start signal8 b=0 is inputted in the state 54, the controller 36 outputs theoscillator control signal 36 a=0 and the counter control signal 36 b=0,thereby stopping the oscillator 5 and holding the counter 37 (state 56).

Further, when the battery 1 is disconnected and the voltage of the powersupply line 1 a lowers in the state 54, the control device fails tofunction (state 51). In the state 55, the controller 36 waits forclearing of the timer start signal 8 b to 0. When the timer start signal8 b=0 is inputted from the microcomputer 7, the state transits to 56while the count value of the counter 37 is held.

In the state 56, the controller 36 waits for setting of the timer startsignal 8 b to 1. When the timer start signal 8 b=1 is set, the counter37 is initialized for transition to the state 53 for the count-upfrom 1. The counter 37 then starts the count-up from 1.

When the battery 1 is disconnected and the voltage of the power supplyline 1 a lowers in any of the states 52 to 56, the control device failsto function and the state transits to 51. In FIG. 5, the oscillator 5 isoperated in the states 53, 54, and the oscillator 5 is stopped in thestates 52, 55 and 56.

The states 53, 54 each represent a state in which the turned-off time ofthe ignition switch 3 is measured with a low consumption current, andthe states 52, 55 and 56 each represent a state in which the oscillatoris also stopped and the consumption current is minimized.

FIG. 5 is a time-serial waveform chart showing the operating state ofthe time measuring timer 10. When the battery 1 is connected to thecontrol device 2, the voltage of the power supply line 1 a rises to thevoltage of the battery 1. When the voltage reaches, at timing 61, alevel at which the control device 2 can be started up, the counter 37 ofthe time measuring timer 10 is initialized to 0 by the power-on resetunit 30 in the regulator 4.

When the ignition switch 3 is turned on at timing 62, the ignitionswitch signal 3 a=1 is inputted to the OR gate 31 of the powercontroller 6, and an output signal 31 a=1 of the OR gate 31 is inputtedto the controller 33. Responsively, the controller 33 outputs the powercontrol signal 6 a=1. Upon receiving the power control signal 6 a=1, thepre-driver 28 in the regulator 4 is enabled to start up the regulator 4.As a result, an output 4 a of the regulator 4 rises to the predeterminedvoltage.

At timing 63 representing a point in time after the microcomputer 7 hasstarted up, the power hold signal 8 a=1 is outputted to the OR gate 31through the SPI 8 with the OS startup process in the microcomputer 7. Atthis time, the microcomputer 7 reads the count value of the counter 37of the time measuring timer 10 through the SPI 8. If the count value ofthe counter 37 of the time measuring timer 10 is 0 (i.e., 37=0), themicrocomputer 7 recognizes that the battery 1 is disconnected.

Also, to measure the turned-on time of the ignition switch 3, themicrocomputer 7 transmits the timer start signal 8 b=1 to the oscillatorcontroller 9 (specifically the controller 36) through the SPI 8. Uponrecognizing the timer start signal 8 b=1, the controller 36 outputs thecounter control signal 36 b=1 to start up the counter 37 of the timemeasuring timer 10. In response to the counter control signal 36 b=1,the counter 37 starts the count-up from h′00001. Thus, the turned-ontime of the ignition switch 3 can be measured with the count-up made bythe counter 37 of the time measuring timer 10.

A period from timing 63 to 64 represents a steady state in whichordinary engine control is performed. During such a period, the counter37 of the time measuring timer 10 continues to count up one per secondfor time measurement. When the ignition switch signal 3 a=0 is inputtedat timing 64, the microcomputer 7 recognizes the turning-off of theignition switch 3 and executes control to stop the engine. Thereafter,the microcomputer 7 executes a process of storing data into a backup RAMand each self-diagnosis process in key-off sequence.

Further, the microcomputer 7 reads the count value of the counter 37 ofthe time measuring timer 10 through the SPI 8. At this time, themicrocomputer 7 first transmits the timer start signal 8 b=0 to thecontroller 36 through the SPI 8, thereby stopping the operation of thecounter 37 of the time measuring timer 10.

Then, the microcomputer 7 reads the count value of the counter 37 of thetime measuring timer 10 through the SPI 8. Simultaneously, the counter37 of the time measuring timer 10 is stopped in a state holding thecount value.

In order to store the ignition turned-on time of a vehicle, i.e., thelifetime during which the engine has actually operated, themicrocomputer 7 writes, in the nonvolatile memory 13, the sum of theread count value and the time stored in the nonvolatile memory 13. Theforegoing is a process for storing the measurement result of theignition turned-on time.

Next, to measure the turned-off time of the ignition switch 3, themicrocomputer 7 transmits the timer start signal 8 b=1 through the SPI8. Upon recognizing the timer start signal 8 b=1, the controller 36outputs the counter control signal 36 b=1 to start up the counter 37 ofthe time measuring timer 10. In response to the counter control signal36 b=1, the counter 37 starts the count-up from h'00001.

When the process for starting up the time measuring timer 10 iscompleted in the microcomputer 7 at timing 65, the microcomputer 7transmits the power hold signal 8 a=0 to the OR gate 31 through the SPI8. The controller 33 recognizes the output signal value 31 a of the ORgate 31 and outputs the power control signal 6 a=0. Further, when thepre-driver 28 in the regulator 4 recognizes the power control signal 6a=0, the operation of the regulator 4 is stopped and the voltage of thepower supply line 4 a lowers.

According to the process described above, the turned-off time of theignition switch 3 can be measured with the count-up made by the counter37 of the time measuring timer 10. This time measurement can be realizedwith a low consumption current because the oscillator 5, the timemeasuring timer 10, and the oscillator controller 9 are only operated.

A description is now made of the operation of the time measuring timer10 when the ignition switch 3 is turned on before the turned-off time ofthe ignition switch 3 reaches 72.8 hours.

When the ignition switch 3 is turned on at timing 66, the regulator 4 isstarted up, thus resulting in a state in which the output voltage 4 a ofthe regulator 4 rises to the predetermined voltage as in the process atthe timing 62. At timing 67 representing a point in time after themicrocomputer 7 has started up, the power hold signal 8 a=1 is outputtedto the OR gate 31 through the SPI 8 with the OS startup process in themicrocomputer 7. At this time, the microcomputer 7 first stops thecounter 37 of the time measuring timer 10.

Then, the microcomputer 7 transmits the timer start signal 8 b=0 throughthe SPI 8. When the controller 36 in the oscillator controller 9recognizes the timer start signal 8 b=0, the controller 36 outputs thecounter control signal 36 b=0 to stop the counter 37.

Upon recognizing the counter control signal 36 b=0, the counter 37 ofthe time measuring timer 10 stops the count-up operation and holds thecount value. Also, after the counter 37 of the time measuring timer 10has stopped the count-up operation, the microcomputer 7 executes a stepof reading the count value. The step of reading the count value isexecuted through the SPI 8.

With the process described above, the microcomputer 7 can measure theturned-off time of the ignition switch 3.

Further, as in the process at the timing 63, to measure the turned-ontime of the ignition switch 3, the microcomputer 7 transmits the timerstart signal 8 b=1 to the controller 9 through the SPI 8. Uponrecognizing the timer start signal 8 b=1, the controller 36 outputs thecounter control signal 36 b=1 to start up the counter 37 of the timemeasuring timer 10. In response to the counter control signal 36 b=1,the counter 37 starts the count-up from h'00001.

A period from timing 67 to 68 represents, like the period from timing 63to 64, a steady state in which ordinary engine control is performed.During such a period, the counter 37 of the time measuring timer 10continues to count up one per second for time measurement. When theignition switch signal 3 a=0 is inputted at timing 68, the microcomputer7 recognizes the turning-off of the ignition switch 3 and executescontrol to stop the engine.

Stated another way, as in the process at the timing 64, the ignitionswitch signal 3 a=0 enables the microcomputer 7 to recognize theturning-off of the ignition switch 3 and to execute control to stop theengine. Thereafter, the microcomputer 7 executes a process of storingdata into a backup RAM and each self-diagnosis process in key-offsequence.

Further, the microcomputer 7 reads the count value of the counter 37 ofthe time measuring timer 10 through the SPI 8. At this time, themicrocomputer 7 first transmits the timer start signal 8 b=0 to thecontroller 36 through the SPI 8, thereby stopping the operation of thecounter 37 of the time measuring timer 10.

Then, the microcomputer 7 reads the count value of the counter 37 of thetime measuring timer 10 through the SPI 8. Simultaneously, the counter37 of the time measuring timer 10 is stopped in a state holding thecount value.

In order to store the ignition turned-on time of the vehicle, i.e., thelifetime during which the engine has actually operated, themicrocomputer 7 writes, in the nonvolatile memory 13, the sum of theread count value and the time stored in the nonvolatile memory 13. Theforegoing is a process for storing the measurement result of theignition turned-on time.

Next, to measure the turned-off time of the ignition switch 3, themicrocomputer 7 transmits the timer start signal 8 b=1 through the SPI8. Upon recognizing the timer start signal 8 b=1, the controller 36outputs the counter control signal 36 b=1 to start up the counter 37 ofthe time measuring timer 10. In response to the counter control signal36 b=1, the counter 37 starts the count-up from h′00001.

When the process for starting up the time measuring timer 10 iscompleted in the microcomputer 7 at timing 69, the microcomputer 7transmits the power hold signal 8 a=0 to the OR gate 31 through the SPI8. The controller 33 recognizes the output signal value 31 a of the ORgate 31 and outputs the power control signal 6 a=0. Further, when thepre-driver 28 in the regulator 4 recognizes the power control signal 6a=0, the operation of the regulator 4 is stopped and the voltage of thepower supply line 4 a lowers.

A description is now made of the case in which the turned-off time ofthe ignition switch 3 exceeds 72.8 hours.

At the timing 69, as described above, the counter 37 of the timemeasuring timer 10 starts the count-up operation. Timing 70 represents apoint in time at which the counter 37 of the time measuring timer 10 hasmeasured the turned-off time of the ignition switch 3 for 72.8 hours,i.e., h′3FFFF seconds.

The overflow sensor 34 in the oscillator controller 9 recognizes h'3FFFFin the counter 37 and outputs the overflow signal 34 a=1 to thecontroller 36.

Upon recognizing the overflow signal 34 a=1, the controller 36 outputsthe oscillator control signal 36 a=0 to stop the oscillation of theoscillator 5, and at the same time it outputs the counter control signal36 b=0 to stop the counter 37 of the time measuring timer 10. Thecontrol signals 36 a, 36 b completely stop the oscillator 5 and thecounter 37, respectively.

According to the process described above, after the counter 37 of thetime measuring timer 10 has measured the turned-off time of the ignitionswitch 3 for 72.8 hours, the consumption current can be further reduced.

A process executed during a period from timing 71 to 72 is basically thesame as that executed during a period from timing 66 to 67. During theperiod from timing 71 to 72, the process differs only in level change ofthe overflow signal 34 a as follows. The overflow signal 34 a causes thetimer start signal 8 b to change from 0 to 1 at the timing 72 and iscleared when the counter 37 of the time measuring timer 10 is restarted.

FIG. 6 is a flowchart of the process executed by the time measuringtimer 10 when the microcomputer 7 is started up. When the ignitionswitch 3 is turned on and the regulator 4 starts the operation, thepredetermined voltage is outputted to the power supply line 4 a and themicrocomputer 7 starts the operation. First, in step 91, themicrocomputer 7 transmits the power hold signal 8 a=1 through the SPI 8for setting the power hold signal 8 a to 1.

Then, in step 92, the microcomputer 7 sets the timer start signal 8 b=0(namely clears the timer start signal 8 b to 0) through the SPI 8 tostop the count-up operation by the counter 37 of the time measuringtimer 10.

Then, in step 93, the microcomputer 7 reads the count value of thecounter 37 of the time measuring timer 10 through the SPI 8. In step 94,it is determined whether the count value is 0 (i.e., the counter 37=0).

If the counter 37=0, processing shifts to step 95 where the occurrenceof battery disconnection is determined because the counter 37=0 meansthat the battery disconnection has occurred during the turned-off periodof the ignition switch 3.

If the counter 37≠0, the microcomputer 7 recognizes the result of thetime measurement during the turned-off period of the ignition switch 3.Then, based on the turned-off time of the ignition switch 3, themicrocomputer 7 predicts the amount by which engine oil has dropped, andcomputes control parameters at the next engine startup in considerationof the predicted amount. (Step 96).

The reading process of the time measuring timer 10 at the startup of themicrocomputer 7 is completed with step 96. In step 97, the microcomputer7 sets the timer start signal 8 b=1 to measure the turned-on time of theignition switch 3, and transits to the ordinary engine control process.

FIG. 7 is a flowchart of the process executed by the time measuringtimer 10 when the microcomputer 7 is stopped. When the microcomputer 7detects the turning-off of the ignition switch 3, the microcomputer 7executes the engine control stopping process, the backup storingprocess, the self-diagnosis process in key-off sequence, and so on.

In step 101, the microcomputer 7 sets the timer start signal 8 b=0(namely clears the timer start signal 8 b to 0) through the SPI 8 tostop the counter 37 of the time measuring timer 10 which has measuredthe turned-on time of the ignition switch 3 so far.

Then, in step 102, the microcomputer 7 reads the count value of thecounter 37 of the time measuring timer 10 through the SPI 8. In step103, the microcomputer 7 adds the accumulative turned-on time of theignition switch 3 stored in the nonvolatile memory 13 and the countvalue of the counter 37 of the time measuring timer 10 which has beenread in step 102, thereby calculating the engine lifetime. Thecalculated result is written in the nonvolatile memory 13 in step 104.

With the process described above, the control device 2 can recognize theaccumulative turned-on time of the ignition switch 3, i.e., the enginelifetime, and can calculate parameter values adapted for aging and othersecular changes of engine auxiliaries, etc. As a result, the enginecontrol can be properly modified.

In step 105, to measure the turned-off time of the ignition switch 3,the microcomputer 7 starts up the counter 37 of the time measuring timer10. Specifically, the microcomputer 7 transmits the timer start signal 8b=1 through the SPI 8.

Then, the power supply is shut down in step 106.

Because the ignition switch 3 is now in the turned-off state, theregulator 4 continues the operation with the power hold signal 8 a=1.Accordingly, the regulator 4 is stopped when the microcomputer 7transmits the power hold signal 8 a=0 through the SPI 8 after the timemeasuring timer 10 has started up.

The features of the above-described embodiment are summarized asfollows.

-   (1) The control device comprises a unit for changing over the    operation of a time measuring unit (timer) depending on an intended    use in accordance with an on/off signal from a power supply switch    (ignition switch) for controlling the turning-on/off of source power    supplied to the control device, or with a control signal from the    microcomputer.-   (2) The intended operation of the time measuring unit is to measure    a turned-on (run) period of the control device, and the control    device further comprises a unit for storing the turned-on period of    the control device in combination with an electrically rewritable    nonvolatile memory.-   (3) The intended operation of the time measuring unit is to measure    a turned-off period of the control device.-   (4) The clock source for the microcomputer and the clock source for    the time measuring unit are individually set up.-   (5) The microcomputer and the time measuring unit are set up as    individual devices.-   (6) The time measuring unit includes a counter for measuring time,    and the control device further comprises a unit for holding a    counter value and a unit for stopping the clock source for the time    measuring unit, when the counter value of the time measuring unit    overflows during the measurement of the turned-off period of the    control device.-   (7) The control device further comprises a unit for starting    count-up of the counter value from a value other than 0 or from 1    when the counter of the time measuring unit is started up.-   (8) The control device further comprises a unit for detecting    whether the battery is connected or disconnected, and a unit for    clearing the counter value of the time measuring unit to 0 when the    battery is connected again from a disconnected state.-   (9) The control device further comprises a unit for controlling    operation of the counter of the time measuring unit from the    microcomputer.-   (10) The control device is set up as an electronic control unit    (ECU) for controlling an automobile engine.

1. A control device with a time measuring function utilized for avehicle, said control device comprising: a microcomputer for computing acontrol variable to control a vehicle component; a timer for measuringtime; a clock source for said microcomputer; and a separate clock sourcefor said timer being independent of said clock source for saidmicrocomputer, wherein said timer regardless of run/stop of saidmicrocomputer, and said microcomputer and said timer are configured tobe electrically supplied from an onboard battery of the vehicle.
 2. Acontrol device with a time measuring function according to claim 1,wherein operation of said timer time is controlled by a power supplyswitch for controlling turning-on/off of said control device.
 3. Acontrol device with a time measuring function according to claim 2,wherein said timer selectively measures a turned-on period or aturned-off period of said power supply switch in accordance with acontrol signal from said microcomputer.
 4. A control device with a timemeasuring function according to claim 2, wherein said timer measures aturned-on period of said power supply switch.
 5. A control device with atime measuring function according to claim 4, further comprising anelectrically rewritable nonvolatile memory and means for storing theturned-on period of said electrical supply from said onboard battery. 6.A control device with a time measuring function according to claim 2,wherein said timer measures a turned-off period of said power supplyswitch.
 7. A control device with a time measuring function according toclaim 1, wherein the clock source for said microcomputer and the clocksource for said timer are individually provided independently of eachother.
 8. A control device with a time measuring function according toclaim 1, wherein said timer includes a counter for measuring time, andsaid control device further comprises means for holding a counter valueand means for stopping the clock source for said timer, when the countervalue of said timer overflows during measurement of the turned-offperiod of said control device.
 9. A control device with a time measuringfunction according to claim 8, further comprising means for startingcount-up of the counter value from a value other than 0 when a counterof said timer is started up.
 10. A control device with a time measuringfunction according to claim 9, wherein said control device furthercomprises means for starting count-up of the counter value from 1 whenthe counter of said timer is started up.
 11. A control device with atime measuring function according to claim 9, further comprising meansfor detecting whether said onboard battery is connected or disconnected,and means for clearing the counter value of said timer to 0 when saidonboard battery is connected again from a disconnected state.
 12. Acontrol device with a time measuring function according to claim 9,further comprising means for controlling operation of the counter ofsaid timer from said microcomputer.